/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Attributes;

import Records.RecordsMain;
import java.util.ArrayList;
import java.util.LinkedList;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Alexander
 */
public class LibraryDataSets {

    public static void InsertLibraryToDatabase(ArrayList DataSet) {
                System.out.println("LibraryDataSets.InsertLibraryToDatabase()");
        String Location = "Directory";

        RecordsMain.dba.insertIntoLibSongs(DataSet.get(0).toString(), //set.add(Song_ID);
                DataSet.get(1).toString(), //set.add(title);
                DataSet.get(8).toString(), //set.add(bpm);
                DataSet.get(4).toString(), //set.add(genre);
                DataSet.get(6).toString(), //set.add(danceability);
                DataSet.get(5).toString(), //set.add(energy);
                DataSet.get(7).toString(),//set.add(acousticness);
                DataSet.get(9).toString(), //set.add(theKey);
                Location,
                DataSet.get(11).toString()); //set.add(FilePathway);

        RecordsMain.dba.insertIntoLibAlbums(DataSet.get(0).toString(), //set.add(Song_ID);
                DataSet.get(3).toString(), //set.add(album);
                DataSet.get(10).toString() //set.add(image);
        );

        RecordsMain.dba.insertIntoLibArtists(DataSet.get(0).toString(), //set.add(Song_ID);
                DataSet.get(2).toString() //set.add(artist);
        );

        insertFilePathToDatabase(DataSet.get(0).toString(), DataSet.get(11).toString());

        addRow(
                DataSet.get(1).toString(), //set.add(title);
                DataSet.get(2).toString(), //set.add(artist);
                DataSet.get(3).toString(), //set.add(album);
                DataSet.get(4).toString(), //set.add(genre);
                DataSet.get(5).toString(), //set.add(energy);
                DataSet.get(6).toString(), //set.add(danceability);
                DataSet.get(7).toString(),//set.add(acousticness);
                DataSet.get(8).toString(), //set.add(bpm);
                DataSet.get(9).toString() //set.add(theKey);
        );

    }

    public static void insertFilePathToDatabase(String Song_ID, String filePath) {
                System.out.println("LibraryDataSets.insertFilePathToDatabase(" + Song_ID + ", " + filePath + ")");

        RecordsMain.dba.insertIntoLibFilePaths(Song_ID, filePath);
    }

    public static void addRow(String title, String artist, String album, String genre, String energy, String danceability, String acousticness, String bpm, String key) {
         System.out.println("LibraryDataSets.addRow(" + title + ", " + artist + album + ", " + genre +energy + ", " + danceability +acousticness + ", " + bpm + ", " + key + ")");
        DefaultTableModel model = (DefaultTableModel) RecordsMain.getUI().userLibrary.getModel();
        LinkedList<Object> songDetails = new LinkedList<>();
        // Build a Vector of Strings for the table row
        songDetails.add(title);
        songDetails.add(artist);
        songDetails.add(album);
        songDetails.add(genre);
        songDetails.add(energy);
        songDetails.add(danceability);
        songDetails.add(acousticness);
        songDetails.add(bpm);
        songDetails.add(key);

        model.addRow(songDetails.toArray());
        RecordsMain.getUI().NumSongs.setText("" + model.getRowCount() + " Songs");
    }
}
